package org.microsites.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.microsites.domain.dao.ServerDAO;
import org.microsites.domain.model.Entity;
import org.microsites.domain.model.Server;
import org.microsites.service.HostService;
import org.microsites.service.ServerService;

public class ServerServiceImpl extends GenericServiceImpl<Server> implements ServerService {

	private ServerDAO serverDAO;
	private HostService hostService;
	
	@Override
	public ServerDAO getDAO() {
		return serverDAO;
	}

	public void setServerDAO(ServerDAO serverDAO) {
		this.serverDAO = serverDAO;
	}

    @Override
    public List<Entity> loadPath(Long id) {
        if (id == null) return new ArrayList<Entity>();

        Server d = this.load(id);
        if (d == null) return new ArrayList<Entity>();
        
        List<Entity> list = hostService.loadPath(d.getHost());
        list.add(d);

        return list;
    }

    public HostService getHostService() {
        return hostService;
    }

    public void setHostService(HostService hostService) {
        this.hostService = hostService;
    }
}
